home *** CD-ROM | disk | FTP | other *** search
/ Mac Magazin/MacEasy 96 / maccd 96.iso / utilities / Mac OS X / DoubleCommand 1.3 / Source / ev_keymap.h < prev    next >
Encoding:
C/C++ Source or Header  |  2002-07-06  |  5.0 KB  |  147 lines

  1.  
  2.  
  3. /*
  4.  * Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved.
  5.  *
  6.  * @APPLE_LICENSE_HEADER_START@
  7.  * 
  8.  * The contents of this file constitute Original Code as defined in and
  9.  * are subject to the Apple Public Source License Version 1.1 (the
  10.  * "License").  You may not use this file except in compliance with the
  11.  * License.  Please obtain a copy of the License at
  12.  * http://www.apple.com/publicsource and read it before using this file.
  13.  * 
  14.  * This Original Code and all software distributed under the License are
  15.  * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  16.  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  17.  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
  18.  * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
  19.  * License for the specific language governing rights and limitations
  20.  * under the License.
  21.  * 
  22.  * @APPLE_LICENSE_HEADER_END@
  23.  */
  24. /*     Copyright (c) 1992 NeXT Computer, Inc.  All rights reserved. 
  25.  *
  26.  *    ev_keymap.h
  27.  *    Defines the structure used for parsing keymappings.  These structures
  28.  *    and definitions are used by event sources in the kernel and by
  29.  *    applications and utilities which manipulate keymaps.
  30.  *    
  31.  * HISTORY
  32.  * 02-Jun-1992    Mike Paquette at NeXT
  33.  *      Created. 
  34.  */
  35.  
  36. #ifndef _DEV_EV_KEYMAP_H
  37. #define _DEV_EV_KEYMAP_H
  38.  
  39. #define    NX_NUMKEYCODES    128    /* Highest key code is 0x7f */
  40. #define NX_NUMSEQUENCES    128    /* Maximum possible number of sequences */
  41. #define    NX_NUMMODIFIERS    16    /* Maximum number of modifier bits */
  42. #define    NX_BYTE_CODES    0    /* If first short 0, all are bytes (else shorts) */
  43.  
  44. #define    NX_WHICHMODMASK    0x0f     /* bits out of keyBits for bucky bits */
  45. #define    NX_MODMASK    0x10    /* Bit out of keyBits indicates modifier bit */
  46. #define    NX_CHARGENMASK    0x20    /* bit out of keyBits for char gen */
  47. #define    NX_SPECIALKEYMASK 0x40    /* bit out of keyBits for specialty key */
  48. #define    NX_KEYSTATEMASK    0x80    /* OBSOLETE - DO NOT USE IN NEW DESIGNS */
  49.  
  50. /*
  51.  * Special keys currently known to and understood by the system.
  52.  * If new specialty keys are invented, extend this list as appropriate.
  53.  * The presence of these keys in a particular implementation is not
  54.  * guaranteed.
  55.  */
  56. #define NX_NOSPECIALKEY            0xFFFF
  57. #define NX_KEYTYPE_SOUND_UP        0
  58. #define NX_KEYTYPE_SOUND_DOWN        1
  59. #define NX_KEYTYPE_BRIGHTNESS_UP    2
  60. #define NX_KEYTYPE_BRIGHTNESS_DOWN    3
  61. #define NX_KEYTYPE_CAPS_LOCK        4
  62. #define NX_KEYTYPE_HELP            5
  63. #define NX_POWER_KEY            6
  64. #define    NX_KEYTYPE_MUTE            7
  65. #define NX_UP_ARROW_KEY            8
  66. #define NX_DOWN_ARROW_KEY        9
  67. #define NX_KEYTYPE_NUM_LOCK        10
  68.  
  69. #define NX_KEYTYPE_CONTRAST_UP        11
  70. #define NX_KEYTYPE_CONTRAST_DOWN    12
  71. #define NX_KEYTYPE_LAUNCH_PANEL        13
  72. #define NX_KEYTYPE_EJECT        14
  73. #define NX_KEYTYPE_VIDMIRROR        15
  74.  
  75. #define    NX_NUMSPECIALKEYS        16 /* Maximum number of special keys */
  76. #define NX_NUM_SCANNED_SPECIALKEYS    16 /* First 16 special keys are */
  77.                       /* actively scanned in kernel */
  78.  
  79. /* Mask of special keys that are posted as events */
  80.  
  81. #define NX_SPECIALKEY_POST_MASK        \
  82.                                 ((1 << NX_KEYTYPE_SOUND_UP) | (1 << NX_KEYTYPE_SOUND_DOWN) | \
  83.                                 (1 << NX_POWER_KEY) | (1 << NX_KEYTYPE_MUTE) | \
  84.                                 (1 << NX_KEYTYPE_BRIGHTNESS_UP) | (1 << NX_KEYTYPE_BRIGHTNESS_DOWN) | \
  85.                                 (1 << NX_KEYTYPE_CONTRAST_UP) | (1 << NX_KEYTYPE_CONTRAST_UP) | \
  86.                                 (1 << NX_KEYTYPE_LAUNCH_PANEL) | (1 << NX_KEYTYPE_EJECT) | \
  87.                                 (1 << NX_KEYTYPE_VIDMIRROR) | 0)
  88.  
  89. /* Modifier key indices into modDefs[] */
  90. #define NX_MODIFIERKEY_ALPHALOCK    0
  91. #define NX_MODIFIERKEY_SHIFT        1
  92. #define NX_MODIFIERKEY_CONTROL        2
  93. #define NX_MODIFIERKEY_ALTERNATE    3
  94. #define NX_MODIFIERKEY_COMMAND        4
  95. #define NX_MODIFIERKEY_NUMERICPAD    5
  96. #define NX_MODIFIERKEY_HELP        6
  97. #define NX_MODIFIERKEY_SECONDARYFN         7
  98. #define NX_MODIFIERKEY_NUMLOCK        8
  99.  
  100.  
  101. typedef struct _NXParsedKeyMapping_ {
  102.      /* If nonzero, all numbers are shorts; if zero, all numbers are bytes*/
  103.     short    shorts;
  104.     
  105.     /*
  106.      *  For each keycode, low order bit says if the key
  107.      *  generates characters.
  108.      *  High order bit says if the key is assigned to a modifier bit.
  109.      *  The second to low order bit gives the current state of the key.
  110.      */
  111.     char    keyBits[NX_NUMKEYCODES];
  112.     
  113.     /* Bit number of highest numbered modifier bit */
  114.     int            maxMod;
  115.     
  116.     /* Pointers to where the list of keys for each modifiers bit begins,
  117.      * or NULL.
  118.      */
  119.     unsigned char *modDefs[NX_NUMMODIFIERS];
  120.     
  121.     /* Key code of highest key deinfed to generate characters */
  122.     int            numDefs;
  123.     
  124.     /* Pointer into the keyMapping where this key's definitions begin */
  125.     unsigned char *keyDefs[NX_NUMKEYCODES];
  126.     
  127.     /* number of sequence definitions */
  128.     int            numSeqs;
  129.     
  130.     /* pointers to sequences */
  131.     unsigned char *seqDefs[NX_NUMSEQUENCES];
  132.     
  133.     /* Special key definitions */
  134.     int            numSpecialKeys;
  135.     
  136.     /* Special key values, or 0xFFFF if none */
  137.     unsigned short specialKeys[NX_NUMSPECIALKEYS];
  138.     
  139.     /* Pointer to the original keymapping string */    
  140.     const unsigned char *mapping;
  141.     
  142.     /* Length of the original string */
  143.     int    mappingLen;    
  144. } NXParsedKeyMapping;
  145.  
  146. #endif /* !_DEV_EV_KEYMAP_H */
  147.